/*
 * JMPISettingsFrame.java
 *
 * Created on 29.03.2009, 22:56:13
 */
package baseservergrid;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Toolkit;
import java.io.File;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JSlider;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import mpiserver.IMpiServer;
import mpiserver.Settings;

/**
 *
 * @author Alex-Rude ID = 2001
 */
public class JMPISettingsFrame extends JFrame {

    IMpiServer mpiServer;
    Settings settings;

    // -------------- Читаем значения переменных из mpiServer.settings ------------
    public void getValuesFromMpiServer() {
        settings = mpiServer.getSettings();
        Component[] component = SettingsPanel.getComponents();
        //-------------------
        for (int i = 0; i < component.length; i++) {
            // Для всех JTextField-ов
            if (component[i].getClass().equals(javax.swing.JTextField.class)) {
                JTextField curTextField = (JTextField) component[i];
                try {
                    curTextField.setText(settings.getField(curTextField.getName()));
                } catch (Exception ex) {
                    try {
                        if (curTextField.getName().equals("@ConfigFile_path@")) {
                            curTextField.setText(mpiServer.getScriptsPath());
                        }
                    } catch (Exception ex2) {
                        System.out.println("Отсутствует статическая переменная: " + curTextField.getName() + "... Задано значение по умолчанию: " + curTextField.getText());
                    }
                }
            }
            // для всех ползунков
            if (component[i].getClass().equals(javax.swing.JSlider.class)) {
                JSlider curSlider = (JSlider) component[i];
                try {
                    String s = settings.getField(curSlider.getName());
                    curSlider.setValue(Integer.decode(s));
                } catch (Exception ex1) {
                    System.out.println("Отсутствует статическая переменная: " + curSlider.getName() + "... Задано значение по умолчанию: " + curSlider.getValue());
                }
            }
        }

    }

    // -------------- Записываем значения переменных в mpiServer.settings ------------
    public void setValuesToMpiServer() {
        Component[] component = SettingsPanel.getComponents();
        //-------------------
        for (int i = 0; i < component.length; i++) {
            // Для всех JTextField-ов
            if (component[i].getClass().equals(javax.swing.JTextField.class)) {
                JTextField curTextField = (JTextField)component[i];
                try {
                    settings.setField(curTextField.getName(), curTextField.getText());
                } catch (Exception ex1) {
                    try {
                        if (curTextField.getName().equals("@ConfigFile_path@")) {
                            mpiServer.setScriptsPath(curTextField.getText());
                        }
                    } catch (Exception ex2) {
                        System.out.println("Отсутствует статическая переменная: " + curTextField.getName() + "... Задано значение по умолчанию: " + curTextField.getText());
                    }
                }
            }

            // для всех ползунков
            if (component[i].getClass().equals(javax.swing.JSlider.class)) {
                JSlider curSlider = (JSlider) component[i];
                try {
                    settings.setField(curSlider.getName(), Long.toString(curSlider.getValue()));
                } catch (Exception ex1) {
                    System.out.println("Отсутствует статическая переменная: " + curSlider.getName() + "... Задано значение по умолчанию: " + curSlider.getValue());
                }
            }
        }
        settings.saveFile();
        mpiServer.setSettings(settings);
        //mpiServer.
    }

    /** Creates new form JMPISettingsFrame */
    public JMPISettingsFrame(IMpiServer mpi) {

        mpiServer = mpi;
        initComponents();
        //---------Позиционирования фрейма по центру экрана-------------
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Dimension sizeScreen = toolkit.getScreenSize();
        int xPos = (sizeScreen.width - this.getWidth()) / 2;
        int yPos = (sizeScreen.height - this.getHeight()) / 2;
        setLocation(new Point(xPos, yPos));
        //Инициализация стиля окна-------------------------------------
        try {
            UIManager.setLookAndFeel(new com.nilo.plaf.nimrod.NimRODLookAndFeel());
            SwingUtilities.updateComponentTreeUI(this);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jDialog1 = new javax.swing.JDialog();
        OKBtn = new javax.swing.JButton();
        CancelBtn = new javax.swing.JButton();
        SettingsPanel = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        SMPD = new javax.swing.JTextField();
        MPI = new javax.swing.JTextField();
        SelectMPIPath = new javax.swing.JButton();
        SelectSMPDPath = new javax.swing.JButton();
        ConfigPathTF = new javax.swing.JTextField();
        SelectScriptPath = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        INCLUDE = new javax.swing.JTextField();
        SelectINCLUDE = new javax.swing.JButton();
        jLabel7 = new javax.swing.JLabel();
        LIB = new javax.swing.JTextField();
        SelectLIB = new javax.swing.JButton();
        GCC = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        SelectGCC = new javax.swing.JButton();
        ppfile_quote = new javax.swing.JSlider();
        QuoteLabel = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();

        javax.swing.GroupLayout jDialog1Layout = new javax.swing.GroupLayout(jDialog1.getContentPane());
        jDialog1.getContentPane().setLayout(jDialog1Layout);
        jDialog1Layout.setHorizontalGroup(
            jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        jDialog1Layout.setVerticalGroup(
            jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );

        setTitle("Настройки модуля взаимодействия с MPI-сервером");
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });
        addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentShown(java.awt.event.ComponentEvent evt) {
                formComponentShown(evt);
            }
        });

        OKBtn.setFont(new java.awt.Font("Calibri", 1, 18));
        OKBtn.setText("OK");
        OKBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                OKBtnActionPerformed(evt);
            }
        });

        CancelBtn.setFont(new java.awt.Font("Calibri", 1, 18)); // NOI18N
        CancelBtn.setText("Отмена");
        CancelBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CancelBtnActionPerformed(evt);
            }
        });

        SettingsPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 204, 204), 1, true), "Настройки"));

        jLabel1.setText("Путь до MPI-сервера:");

        jLabel2.setText("Путь до SMPD-сервера:");

        jLabel4.setText("Директория скриптов:");

        SMPD.setText("C:\\Program Files\\MPICH2\\bin\\SMPD.exe");
        SMPD.setName("@SMPD@"); // NOI18N
        SMPD.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SMPDActionPerformed(evt);
            }
        });

        MPI.setText("C:\\Program Files\\MPICH2\\bin\\wmpiexec.exe");
        MPI.setName("@MPI@"); // NOI18N
        MPI.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                MPIActionPerformed(evt);
            }
        });

        SelectMPIPath.setText("...");
        SelectMPIPath.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SelectMPIPathActionPerformed(evt);
            }
        });

        SelectSMPDPath.setText("...");
        SelectSMPDPath.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SelectSMPDPathActionPerformed(evt);
            }
        });

        ConfigPathTF.setText("mpiconfig");
        ConfigPathTF.setName("@ConfigFile_path@"); // NOI18N
        ConfigPathTF.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ConfigPathTFActionPerformed(evt);
            }
        });

        SelectScriptPath.setText("...");
        SelectScriptPath.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SelectScriptPathActionPerformed(evt);
            }
        });

        jLabel6.setText("Директория INCLUDE:");

        INCLUDE.setName("@INCLUDE@"); // NOI18N
        INCLUDE.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                INCLUDEActionPerformed(evt);
            }
        });

        SelectINCLUDE.setText("...");
        SelectINCLUDE.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SelectINCLUDEActionPerformed(evt);
            }
        });

        jLabel7.setText("Директория LIB:");

        LIB.setName("@LIB@"); // NOI18N
        LIB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                LIBActionPerformed(evt);
            }
        });

        SelectLIB.setText("...");
        SelectLIB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SelectLIBActionPerformed(evt);
            }
        });

        GCC.setName("@GCC@"); // NOI18N
        GCC.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                GCCActionPerformed(evt);
            }
        });

        jLabel9.setText("Путь к GCC:");

        SelectGCC.setText("...");
        SelectGCC.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SelectGCCActionPerformed(evt);
            }
        });

        ppfile_quote.setMaximum(15000);
        ppfile_quote.setMinimum(1000);
        ppfile_quote.setPaintTicks(true);
        ppfile_quote.setValue(5000);
        ppfile_quote.setName("ppfile_quote"); // NOI18N
        ppfile_quote.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                ppfile_quoteStateChanged(evt);
            }
        });

        QuoteLabel.setText("5000 kb");

        jLabel5.setText("Квота на размер LOG-файла:");

        javax.swing.GroupLayout SettingsPanelLayout = new javax.swing.GroupLayout(SettingsPanel);
        SettingsPanel.setLayout(SettingsPanelLayout);
        SettingsPanelLayout.setHorizontalGroup(
            SettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(SettingsPanelLayout.createSequentialGroup()
                .addGroup(SettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(SettingsPanelLayout.createSequentialGroup()
                        .addGroup(SettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addComponent(jLabel2))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(SettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(SMPD, javax.swing.GroupLayout.DEFAULT_SIZE, 392, Short.MAX_VALUE)
                            .addComponent(MPI, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 392, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(SettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(SelectMPIPath, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(SelectSMPDPath, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, SettingsPanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(SettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, SettingsPanelLayout.createSequentialGroup()
                                .addGroup(SettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabel6)
                                    .addComponent(jLabel7)
                                    .addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, 116, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(SettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, SettingsPanelLayout.createSequentialGroup()
                                        .addComponent(ConfigPathTF, javax.swing.GroupLayout.DEFAULT_SIZE, 386, Short.MAX_VALUE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(SelectScriptPath, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(SettingsPanelLayout.createSequentialGroup()
                                        .addComponent(INCLUDE, javax.swing.GroupLayout.DEFAULT_SIZE, 386, Short.MAX_VALUE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(SelectINCLUDE, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, SettingsPanelLayout.createSequentialGroup()
                                        .addGroup(SettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(GCC, javax.swing.GroupLayout.DEFAULT_SIZE, 386, Short.MAX_VALUE)
                                            .addComponent(LIB, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 386, Short.MAX_VALUE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(SettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(SelectLIB, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(SelectGCC, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                            .addGroup(SettingsPanelLayout.createSequentialGroup()
                                .addGap(1, 1, 1)
                                .addComponent(jLabel5)
                                .addGap(18, 18, 18)
                                .addComponent(ppfile_quote, javax.swing.GroupLayout.DEFAULT_SIZE, 337, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(QuoteLabel)))))
                .addContainerGap())
        );
        SettingsPanelLayout.setVerticalGroup(
            SettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(SettingsPanelLayout.createSequentialGroup()
                .addGroup(SettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(MPI, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1)
                    .addComponent(SelectMPIPath))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(SettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(SMPD, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2)
                    .addComponent(SelectSMPDPath))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(SettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(ConfigPathTF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(SelectScriptPath))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(SettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(SelectINCLUDE)
                    .addComponent(INCLUDE, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(SettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(SelectLIB)
                    .addComponent(LIB, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(SettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(GCC, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(SelectGCC)
                    .addComponent(jLabel9))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(SettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(QuoteLabel)
                    .addComponent(ppfile_quote, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5)))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(SettingsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(OKBtn, javax.swing.GroupLayout.DEFAULT_SIZE, 182, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(CancelBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 164, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(233, 233, 233))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(SettingsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(OKBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(CancelBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void MPIActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MPIActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_MPIActionPerformed

    private void SMPDActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SMPDActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_SMPDActionPerformed

    //---------------------- Изменение положения слайдера квоты -----------
    private void ppfile_quoteStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_ppfile_quoteStateChanged
        QuoteLabel.setText(ppfile_quote.getValue() + " kb");
}//GEN-LAST:event_ppfile_quoteStateChanged

    private void OKBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_OKBtnActionPerformed
        //---- закрываем окно. Сохраняем все параметры
        setValuesToMpiServer();
        this.setVisible(false);
}//GEN-LAST:event_OKBtnActionPerformed

    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
    }//GEN-LAST:event_formWindowOpened

    private void CancelBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CancelBtnActionPerformed
        // закрываем окно не сохраняя параметры
        this.setVisible(false);
        //Тестовый комментарии
    }//GEN-LAST:event_CancelBtnActionPerformed

    private void formComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentShown
        // Загружаем значения параметров в компоненты отображения        
        getValuesFromMpiServer();
    }//GEN-LAST:event_formComponentShown

    /**
     * Вызывает окно диалога выбора файла, и записывает абсолютный путь до файла
     * в заданное текстовое поле
     * @param SelectedPath - Если файл уже был выбран, то это путь к нему, 
     * иначе - параметр игнорируется
     * @param tf - текстовое поле, в которое будет записано значение выбранного пути
     */
    private void SelectDialogPathToTextField(String SelectedPath, JTextField tf) {
        JFileChooser fd = new JFileChooser();
        File SF = new File(SelectedPath.substring(1, SelectedPath.length() - 1));
        if (SF.exists()) {
            fd.setSelectedFile(SF);
        }
        File f;
        if (fd.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
            tf.setText("\"" + fd.getSelectedFile().getAbsolutePath() + "\"");
        }

    }

    private void SelectMPIPathActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SelectMPIPathActionPerformed
        SelectDialogPathToTextField(MPI.getText(), MPI);
}//GEN-LAST:event_SelectMPIPathActionPerformed

    private void SelectSMPDPathActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SelectSMPDPathActionPerformed
        SelectDialogPathToTextField(SMPD.getText(), SMPD);
    }//GEN-LAST:event_SelectSMPDPathActionPerformed

    private void SelectScriptPathActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SelectScriptPathActionPerformed
        SelectDialogPathToTextField(ConfigPathTF.getText(), ConfigPathTF);
}//GEN-LAST:event_SelectScriptPathActionPerformed

    private void INCLUDEActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_INCLUDEActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_INCLUDEActionPerformed

    private void SelectINCLUDEActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SelectINCLUDEActionPerformed
        // TODO add your handling code here:
        SelectDialogPathToTextField(INCLUDE.getText(), INCLUDE);
}//GEN-LAST:event_SelectINCLUDEActionPerformed

    private void LIBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LIBActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_LIBActionPerformed

    private void SelectLIBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SelectLIBActionPerformed
        SelectDialogPathToTextField(LIB.getText(), LIB);
}//GEN-LAST:event_SelectLIBActionPerformed

    private void GCCActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_GCCActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_GCCActionPerformed

    private void SelectGCCActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SelectGCCActionPerformed
        // TODO add your handling code here:
        SelectDialogPathToTextField(GCC.getText(), GCC);
}//GEN-LAST:event_SelectGCCActionPerformed

    private void ConfigPathTFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ConfigPathTFActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_ConfigPathTFActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton CancelBtn;
    private javax.swing.JTextField ConfigPathTF;
    private javax.swing.JTextField GCC;
    private javax.swing.JTextField INCLUDE;
    private javax.swing.JTextField LIB;
    private javax.swing.JTextField MPI;
    private javax.swing.JButton OKBtn;
    private javax.swing.JLabel QuoteLabel;
    private javax.swing.JTextField SMPD;
    private javax.swing.JButton SelectGCC;
    private javax.swing.JButton SelectINCLUDE;
    private javax.swing.JButton SelectLIB;
    private javax.swing.JButton SelectMPIPath;
    private javax.swing.JButton SelectSMPDPath;
    private javax.swing.JButton SelectScriptPath;
    private javax.swing.JPanel SettingsPanel;
    private javax.swing.JDialog jDialog1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JSlider ppfile_quote;
    // End of variables declaration//GEN-END:variables
}
